package io.renren.modules.alarmonline.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.labonin.entity.LableonlineinfoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.alarmonline.entity.AreaalarmOnlineEntity;
import io.renren.modules.alarmonline.service.AreaalarmOnlineService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-30 15:43:53
 */
@RestController
@RequestMapping("alarmonline/areaalarmonline")
public class AreaalarmOnlineController {
    @Autowired
    private AreaalarmOnlineService areaalarmOnlineService;


    @PostMapping(value = "/add",produces = {"application/json;charset=UTF-8"})
    public void addItem(@RequestBody AreaalarmOnlineEntity areaalarmOnlineEntity){
        areaalarmOnlineService.insertItem(areaalarmOnlineEntity);
    }


    @PostMapping(value = "/remove",produces = {"application/json;charset=UTF-8"})
    public void removeAlarm(){
        areaalarmOnlineService.deleteAllAlarm();
    }

    //根据姓名查询
    @GetMapping(value = "/selectByEmpName",produces = {"application/json;charset=UTF-8"})
    public List<AreaalarmOnlineEntity> selectByEmpName(@RequestParam("empName") String empName){
        return areaalarmOnlineService.selectByEmpName(empName);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("alarmonline:areaalarmonline:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = areaalarmOnlineService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{areaalarmNo}")
   // @RequiresPermissions("alarmonline:areaalarmonline:info")
    public R info(@PathVariable("areaalarmNo") Integer areaalarmNo){
		AreaalarmOnlineEntity areaalarmOnline = areaalarmOnlineService.getById(areaalarmNo);

        return R.ok().put("areaalarmOnline", areaalarmOnline);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   // @RequiresPermissions("alarmonline:areaalarmonline:save")
    public R save(@RequestBody AreaalarmOnlineEntity areaalarmOnline){
		areaalarmOnlineService.save(areaalarmOnline);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("alarmonline:areaalarmonline:update")
    public R update(@RequestBody AreaalarmOnlineEntity areaalarmOnline){
		areaalarmOnlineService.updateById(areaalarmOnline);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // @RequiresPermissions("alarmonline:areaalarmonline:delete")
    public R delete(@RequestBody Integer[] areaalarmNos){
		areaalarmOnlineService.removeByIds(Arrays.asList(areaalarmNos));

        return R.ok();
    }

}
